package ACWing.mathematicalknowledge.欧拉函数;
//874. 筛法求欧拉函数

import java.util.Scanner;

/**
 * @author :chenjie
 * @date :Created 2023/1/11 16:20
 */
public class FindEulerFunctionSieve {
    static boolean[]st=new boolean[1000010];
    static int[]arr=new int[1000010];
    static int cnt,n;
    static int[]phi=new int[1000010];
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        n=sc.nextInt();
        System.out.println(get_euler(n));
    }
    public static long get_euler(int n){
        phi[1]=1;
        for (int i = 2; i <= n; i++) {
            if(!st[i]){
                arr[cnt++]=i;
                phi[i]=i-1;
            }
            for (int j = 0; arr[j]<=n/i; j++) {
                st[arr[j]*i]=true;
                if(i%arr[j]==0){
                    phi[arr[j]*i]=arr[j]*phi[i];
                    break;
                }
                phi[arr[j]*i]=(arr[j]-1)*phi[i];
            }
        }
        long sum=0;
        for (int i = 1; i <= n; i++) {
            sum+=phi[i];
        }
        return sum;
    }
}
